home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 39 / Amiga Format CD39 (1999-04-13)(Future Publishing)(GB)[!][issue 1999-05].iso / -seriously_amiga- / graphics / ripley / source / display.c < prev    next >
C/C++ Source or Header  |  1999-03-02  |  4KB  |  171 lines

  1. /* display.c, Picasso IV PiP interface */
  2.  
  3. /* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
  4. // Frank Pagels, 1998
  5.  
  6. /*
  7.  * Disclaimer of Warranty
  8.  *
  9.  * These software programs are available to the user without any license fee or
  10.  * royalty on an "as is" basis.  The MPEG Software Simulation Group disclaims
  11.  * any and all warranties, whether express, implied, or statuary, including any
  12.  * implied warranties or merchantability or of fitness for a particular
  13.  * purpose.  In no event shall the copyright-holder be liable for any
  14.  * incidental, punitive, or consequential damages of any kind whatsoever
  15.  * arising from the use of these programs.
  16.  *
  17.  * This disclaimer of warranty extends to the user of these programs and user's
  18.  * customers, employees, agents, transferees, successors, and assigns.
  19.  *
  20.  * The MPEG Software Simulation Group does not represent or warrant that the
  21.  * programs furnished hereunder are free of infringement of any third-party
  22.  * patents.
  23.  *
  24.  * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
  25.  * are subject to royalty fees to patent holders.  Many of these patents are
  26.  * general enough such that they are unavoidable regardless of implementation
  27.  * design.
  28.  *
  29.  */
  30.  
  31. #include <stdio.h>
  32. #include <stdlib.h>
  33.  
  34. #include "config.h"
  35. #include "global.h"
  36.  
  37. #include "mplay.h"
  38. #include "screen.h"
  39. #include "commandline.h"
  40.  
  41. #include <proto/exec.h>
  42. #include <proto/dos.h>
  43. #include <proto/picasso96.h>
  44. #include <proto/guigfx.h>
  45. #include <proto/intuition.h>
  46. #include <proto/gadtools.h>
  47. #include <proto/graphics.h>
  48. #include <guigfx/guigfx.h>
  49.  
  50. #include <clib/macros.h>
  51.  
  52. #ifdef __PPC__
  53. #include <powerup/ppclib/interface.h>
  54. #include <powerup/ppclib/time.h>
  55. //#include <powerup/gcclib/powerup_protos.h>
  56. //#include <proto/ppc.h>
  57. #endif
  58.  
  59.  
  60. struct mvscreen *mvscreen = NULL;
  61. struct mvwindow *mvwindow = NULL;
  62.  
  63. static BOOL initialized = FALSE;
  64.  
  65.  
  66.  
  67. void Terminate_Display_Process();
  68.  
  69.  
  70.  
  71. void Initialize_Display_Process(char *name)
  72. {
  73.     BOOL success = FALSE;
  74.  
  75.  
  76.     if (!initialized)
  77.     {
  78.         int framerate = 0;
  79.         
  80.         if (opts[OPT_FRAMERATE])
  81.         {
  82.             framerate = *((LONG *)opts[OPT_FRAMERATE]);
  83.         }
  84.     
  85.         if (mvscreen = CreateMVScreen())
  86.         {
  87.             if (mvwindow = CreateMVWindow(mvscreen, opts[OPT_PIP], horizontal_size, vertical_size, opts[OPT_GREY], name, framerate))
  88.             {
  89.     #ifdef __PPC__
  90.                 struct TagItem ctoTags[] = { {PPCTIMERTAG_CPU, TRUE},{TAG_END, 0} };
  91.                 ULONG *Tick[2];
  92.     #endif
  93.                 if (opts[OPT_SNAP])
  94.                 {
  95.                     int borderWidth, borderHeight;
  96.                     UpdateWindowParameters(mvwindow);
  97.                     borderWidth = mvwindow->winwidth - mvwindow->innerwidth;
  98.                     borderHeight = mvwindow->winheight - mvwindow->innerheight;
  99.                     
  100.                     SizeWindow(mvwindow->window,
  101.                         (horizontal_size + borderWidth) - mvwindow->winwidth,
  102.                         (vertical_size + borderHeight) - mvwindow->winheight);
  103.                         
  104.                     MoveWindow(mvwindow->window,
  105.                         -((horizontal_size + borderWidth) - mvwindow->winwidth)/2,
  106.                         -((vertical_size + borderHeight) - mvwindow->winheight)/2);
  107.                     
  108.                 }
  109.             
  110.                 initialized = TRUE;
  111.                 success = TRUE;
  112.     
  113.     #ifdef __PPC__
  114.                 mvwindow->timerObject=PPCCreateTimerObject(ctoTags);
  115.                 PPCGetTimerObject(mvwindow->timerObject,PPCTIMERTAG_TICKSPERSEC,&Tick);
  116.                 mvwindow->ticks=(long)Tick[1]/1000; /* tick per second*/
  117.     #endif
  118.             }
  119.             else
  120.             {
  121.             doneFlag = TRUE;
  122.             printf("Can't open window!\n");
  123.             }
  124.         }
  125.         else
  126.         {
  127.             doneFlag = TRUE;
  128.             printf("Can't open screen!\n");
  129.         }
  130.     }
  131.  
  132. }
  133.  
  134.  
  135. void Terminate_Display_Process()
  136. {
  137.   if (mvwindow)
  138.   {    
  139.     mvwindow->frame = 0;
  140.     
  141.     if (!(!doneFlag && opts[OPT_LOOP]))
  142.     {
  143.         if (mvwindow)
  144.         {
  145.             DeleteMVWindow(mvwindow);
  146.         }
  147.         
  148.         if (mvscreen)
  149.         {
  150.             DeleteMVScreen(mvscreen);
  151.         }
  152.  
  153. #ifdef __PPC__
  154.           if (mvwindow->timerObject)
  155.           {
  156.               PPCDeleteTimerObject(mvwindow->timerObject);
  157.         }
  158. #endif
  159.  
  160.     }
  161.   }
  162. }
  163.  
  164.  
  165. void Display_Image(src)
  166. unsigned char *src[];
  167. {
  168.     doneFlag = !mplay(mvwindow, src);
  169. }
  170.  
  171.